
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Form elements</title>

    <!-- Main Styles -->
    <link rel="stylesheet" href="../../static/styles/style.min.css">

    <!-- Material Design Icon -->
    <link rel="stylesheet" href="../../static/fonts/material-design/css/materialdesignicons.css">

    <!-- mCustomScrollbar -->
    <link rel="stylesheet" href="../../static/plugin/mCustomScrollbar/jquery.mCustomScrollbar.min.css">

    <!-- Waves Effect -->
    <link rel="stylesheet" href="../../static/plugin/waves/waves.min.css">

    <!-- Sweet Alert -->
    <link rel="stylesheet" href="../../static/plugin/sweet-alert/sweetalert.css">

    <!-- Dark Themes -->
<!--    <link rel="stylesheet" href="../../static/styles/style-black.min.css">-->
</head>

<body>
<div id="page1">
</div>

<div id="wrapper">
    <div class="main-content" >
        <div class="row small-spacing">
            <div class="col-lg-6 col-xs-12">
                <div class="box-content card white"  style="margin: 0 auto">
                    <h4 class="box-title">密码修改</h4>
                    <!-- /.box-title -->
                    <div class="card-content">
                        <form class="form-horizontal">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">原密码</label>
                                <div class="col-sm-10">
                                    <input type="hidden" id="pwd" >
                                    <input type="text" class="form-control" id="oldPwd" placeholder="请输入原密码">
                                </div>
                            </div>
                            <div class="form-group">
                                <label  class="col-sm-2 control-label">新密码</label>
                                <div class="col-sm-10">
                                    <input type="password" class="form-control" id="newPwd" placeholder="请输入新密码">
                                </div>
                            </div>
                            <div class="form-group margin-bottom-0">
                                <div class="col-sm-offset-2 col-sm-10">
                                    <button  onclick="updatePwd()" type="button" class="btn btn-info btn-sm waves-effect waves-light">确认修改</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
             </div>
    </div>
</div><!--/#wrapper -->

<script src="../../static/scripts/jquery.min.js"></script>
<script src="../../static/scripts/modernizr.min.js"></script>
<script src="../../static/plugin/bootstrap/js/bootstrap.min.js"></script>
<script src="../../static/plugin/mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="../../static/plugin/nprogress/nprogress.js"></script>
<script src="../../static/plugin/sweet-alert/sweetalert.min.js"></script>
<script src="../../static/plugin/waves/waves.min.js"></script>
<script type="text/javascript">
    $(function () {

        $(document).ready(function() {
            $("#page1").load("/menu");
        });


    })

    function updatePwd() {
            $.ajax({
                url: "/user/updatePassword",
                type: "post",
                data: {
                    oldPwd :$("#oldPwd").val(),
                    newPwd :$("#newPwd").val(),
                },
                async: false,
                success: function (obj) {
                    if (obj.result){
                        window.location.href = "/user/userList";
                    }else {
                        alert("原密码输入有误，请重新输入")
                    }
                }
            });
    }
</script>
</body>
</html>